<?php
/**
 * The Template for displaying product archives, including the main shop page which is a post type archive.
 *
 * Override this template by copying it to yourtheme/woocommerce/archive-product.php
 *
 * @author 		WooThemes
 * @package 	WooCommerce/Templates
 * @version     2.0.0
 */

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
?>

<?php global $data; ?>
<?php get_header('shop'); ?>

	<?php do_action('woocommerce_before_main_content'); ?>

	<!-- BEGIN #main-content -->
	<div <?php echo sidebar_position('primary-content'); ?>>

		<h1 class="page-title">

			<?php if ( is_search() ) : ?>
						
				<?php printf( __( 'Search Results: &ldquo;%s&rdquo;', 'woocommerce' ), get_search_query() ); ?>
					
				<?php if ( get_query_var( 'paged' ) ) ?>
					<?php //printf( __( '&nbsp;&ndash; Page %s', 'woocommerce' ), get_query_var( 'paged' ) ); ?>
				<?php elseif ( is_tax() ) : ?>
					<?php echo single_term_title( "", false ); ?>					
				<?php else : ?>
					<?php $shop_page = get_post( woocommerce_get_page_id( 'shop' ) ); ?>
					<?php echo apply_filters( 'the_title', ( $shop_page_title = get_option( 'woocommerce_shop_page_title' ) ) ? $shop_page_title : $shop_page->post_title ); ?>
						
			<?php endif; ?>
					
		</h1>
		
		<!-- BEGIN .breadcrumb-order-wrapper -->
		<div class="breadcrumb-order-wrapper">
			<?php if (function_exists('woocommerce_breadcrumb')) woocommerce_breadcrumb(); ?>
			<?php //if (function_exists('woocommerce_catalog_ordering')) woocommerce_catalog_ordering(); ?>
		<!-- END .breadcrumb-order-wrapper -->
		</div>
				
		<!-- BEGIN .page-content -->
		<div class="page-content">
			
			<?php echo woocommerce_show_messages(); ?>
				
			<?php do_action( 'woocommerce_archive_description' ); ?>

			<?php if ( is_tax() ) : ?>
				<?php do_action( 'woocommerce_taxonomy_archive_description' ); ?>
			<?php elseif ( ! empty( $shop_page ) && is_object( $shop_page ) ) : ?>
				<?php do_action( 'woocommerce_product_archive_description', $shop_page ); ?>
			<?php endif; ?>

			<?php if ( have_posts() ) : ?>

				<?php //do_action('woocommerce_before_shop_loop'); ?>
					
				<?php if( $data['shop_columns'] ) {
					$shop_columns = $data['shop_columns'];
				} else {
					$shop_columns = '4';
				} ?>
				
                                <!-- <ul class="products clearfix"> -->
				<ul class="products products-col-<?php echo $shop_columns; ?> clearfix">
                                    <?php woocommerce_product_subcategories(); ?>
                                </ul>
                                
				<!-- <ul class="products clearfix"> -->
				<ul class="products products-col-<?php echo $shop_columns; ?> clearfix">

					<?php //woocommerce_product_subcategories(); ?>

					<?php while ( have_posts() ) : the_post(); ?>
						<?php woocommerce_get_template_part( 'content', 'product' ); ?>
					<?php endwhile; // end of the loop. ?>

				</ul>

				<?php do_action('woocommerce_after_shop_loop'); ?>

			<?php else : ?>

				<?php /*if ( ! woocommerce_product_subcategories( array( 'before' => '<ul class="products">', 'after' => '</ul>' ) ) ) : ?>
					<p>No se han encontrado productos que se ajusten a su selecci&oacute;n</p>
				<?php endif;*/ ?>

			<?php endif; ?>

			<div class="clear"></div>

			<?php do_action( 'woocommerce_pagination' ); ?>
			
		<!-- END .page-content -->
		</div>
		
	<!-- BEGIN #main-content -->
	</div>
				
<?php get_sidebar(); ?>
<?php do_action('woocommerce_after_main_content'); ?>
<?php do_action('woocommerce_sidebar'); ?>
<?php get_footer('shop'); ?>